<%@ page import="org.ikastola.Student" %>

<g:javascript src="jquery.multiselect.filter.js" />
<g:javascript src="jquery.multiselect.js" />
<script type="text/javascript">
	$(document).ready(function() {
		$("#guardians").multiselect().multiselectfilter();
/*		$("#nationality").multiselect({
			multiple: false
			}).multiselectfilter(); */
/*		$("#service").multiselect({
			multiple: false
			}).multiselectfilter(); */
		$("#fees").multiselect().multiselectfilter();
		$("#disc").multiselect().multiselectfilter();
		$("#relatives").multiselect().multiselectfilter();
	});
</script>

<div class="fieldcontain ${hasErrors(bean: studentInstance, field: 'name', 'error')} required">
	<label for="name">
		<g:message code="student.name.label" default="Name" />
		<span class="required-indicator">*</span>
	</label>
	<g:textField name="name" required="" value="${studentInstance?.name}"/>
</div>

<div class="fieldcontain ${hasErrors(bean: studentInstance, field: 'lastname', 'error')} required">
	<label for="lastname">
		<g:message code="student.lastname.label" default="Lastname" />
		<span class="required-indicator">*</span>
	</label>
	<g:textField name="lastname" required="" value="${studentInstance?.lastname}"/>
</div>

<div class="fieldcontain ${hasErrors(bean: studentInstance, field: 'doctype', 'error')} ">
	<label for="doctype">
		<g:message code="student.doctype.label" default="Doctype" />
		
	</label>
	<g:select name="doctype" from="${studentInstance.constraints.doctype.inList}" value="${studentInstance?.doctype}" valueMessagePrefix="student.doctype"/>
</div>

<div class="fieldcontain ${hasErrors(bean: studentInstance, field: 'docnumber', 'error')} required">
	<label for="docnumber">
		<g:message code="student.docnumber.label" default="Docnumber" />
		<span class="required-indicator">*</span>
	</label>
	<g:textField name="docnumber" required="" value="${studentInstance?.docnumber}"/>
</div>

<div class="fieldcontain ${hasErrors(bean: studentInstance, field: 'birthdate', 'error')} required">
	<label for="birthdate">
		<g:message code="student.birthdate.label" default="Birthdate" />
		<span class="required-indicator">*</span>
	</label>
	<g:datePicker name="birthdate" precision="day"  value="${studentInstance?.birthdate}"  />
</div>

<div class="fieldcontain ${hasErrors(bean: studentInstance, field: 'nationality', 'error')} required">
	<label for="nationality">
		<g:message code="student.nationality.label" default="Nationality" />
		<span class="required-indicator">*</span>
	</label>
	<select name="nationality" id="nationality">
		<option value="ARG">Argentina</option>
		<option value="AFG">Afganistán</option>
		<option value="ALA">Aland</option>
		<option value="ALB">Albania</option>
		<option value="DEU">Alemania</option>
		<option value="AND">Andorra</option>
		<option value="AGO">Angola</option>
		<option value="AIA">Anguila</option>
		<option value="ATG">Antigua y Barbuda</option>
		<option value="ANT">Antillas Neerlandesas</option>
		<option value="SAU">Arabia Saudita</option>
		<option value="DZA">Argelia</option>
		<option value="ARM">Armenia</option>
		<option value="ABW">Aruba</option>
		<option value="AUS">Australia</option>
		<option value="AUT">Austria</option>
		<option value="AZE">Azerbaiyán</option>
		<option value="BHS">Bahamas</option>
		<option value="BHR">Baréin</option>
		<option value="BGD">Bangladés</option>
		<option value="BRB">Barbados</option>
		<option value="BEL">Bélgica</option>
		<option value="BLZ">Belice</option>
		<option value="BEN">Benín</option>
		<option value="BMU">Bermudas</option>
		<option value="BLR">Bielorrusia</option>
		<option value="MMR">Birmania</option>
		<option value="BOL">Bolivia</option>
		<option value="BIH">Bosnia y Herzegovina</option>
		<option value="BWA">Botsuana</option>
		<option value="BVT">IslaBouvet</option>
		<option value="BRA">Brasil</option>
		<option value="BRN">Brunéi</option>
		<option value="BGR">Bulgaria</option>
		<option value="BFA">BurkinaFaso</option>
		<option value="BDI">Burundi</option>
		<option value="BTN">Bután</option>
		<option value="CPV">CaboVerde</option>
		<option value="CYM">IslasCaimán</option>
		<option value="KHM">Camboya</option>
		<option value="CMR">Camerún</option>
		<option value="CAN">Canadá</option>
		<option value="CAF">República Centroafricana</option>
		<option value="TCD">Chad</option>
		<option value="CZE">RepúblicaCheca</option>
		<option value="CHL">Chile</option>
		<option value="CHN">China</option>
		<option value="CYP">Chipre</option>
		<option value="CCK">Islas Cocos</option>
		<option value="COL">Colombia</option>
		<option value="COM">Comoras</option>
		<option value="COG">RepúblicadelCongo</option>
		<option value="COD">Rep.Dem.delCongo</option>
		<option value="COK">IslasCook</option>
		<option value="PRK">Corea del Norte</option>
		<option value="KOR">Corea del Sur</option>
		<option value="CIV">Costa de Marfil</option>
		<option value="CRI">Costa Rica</option>
		<option value="HRV">Croacia</option>
		<option value="CUW">Curazao</option>
		<option value="CUB">Cuba</option>
		<option value="DNK">Dinamarca</option>
		<option value="DMA">Dominica</option>
		<option value="DOM">República Dominicana</option>
		<option value="ECU">Ecuador</option>
		<option value="EGY">Egipto</option>
		<option value="SLV">ElSalvador</option>
		<option value="ARE">Emiratos Arabes Unidos</option>
		<option value="ERI">Eritrea</option>
		<option value="SVK">Eslovaquia</option>
		<option value="SVN">Eslovenia</option>
		<option value="ESP">España</option>
		<option value="USA">Estados Unidos</option>
		<option value="EST">Estonia</option>
		<option value="ETH">Etiopía</option>
		<option value="FRO">Islas Feroe</option>
		<option value="PHL">Filipinas</option>
		<option value="FIN">Finlandia</option>
		<option value="FJI">Fiyi</option>
		<option value="FRA">Francia</option>
		<option value="GAB">Gabón</option>
		<option value="GMB">Gambia</option>
		<option value="GEO">Georgia</option>
		<option value="GHA">Ghana</option>
		<option value="GIB">Gibraltar</option>
		<option value="GRD">Granada</option>
		<option value="GRC">Grecia</option>
		<option value="GRL">Groenlandia</option>
		<option value="GLP">Guadalupe</option>
		<option value="GUM">Guam</option>
		<option value="GTM">Guatemala</option>
		<option value="GUF">Guayana Francesa</option>
		<option value="GGY">Guernsey</option>
		<option value="GIN">Guinea</option>
		<option value="GNQ">Guinea Ecuatorial</option>
		<option value="GNB">Guinea-Bisáu</option>
		<option value="GUY">Guyana</option>
		<option value="HTI">Haití</option>
		<option value="HMD">Islas Heardy McDonald</option>
		<option value="HND">Honduras</option>
		<option value="HKG">HongKong</option>
		<option value="HUN">Hungría</option>
		<option value="IND">India</option>
		<option value="IDN">Indonesia</option>
		<option value="IRN">Irán</option>
		<option value="IRQ">Irak</option>
		<option value="IRL">Irlanda</option>
		<option value="ISL">Islandia</option>
		<option value="ISR">Israel</option>
		<option value="ITA">Italia</option>
		<option value="JAM">Jamaica</option>
		<option value="JPN">Japón</option>
		<option value="JEY">Jersey</option>
		<option value="JOR">Jordania</option>
		<option value="KAZ">Kazajistán</option>
		<option value="KEN">Kenia</option>
		<option value="KGZ">Kirguistán</option>
		<option value="KIR">Kiribati</option>
		<option value="KWT">Kuwait</option>
		<option value="LAO">Laos</option>
		<option value="LSO">Lesoto</option>
		<option value="LVA">Letonia</option>
		<option value="LBN">Líbano</option>
		<option value="LBR">Liberia</option>
		<option value="LBY">Libia</option>
		<option value="LIE">Liechtenstein</option>
		<option value="LTU">Lituania</option>
		<option value="LUX">Luxemburgo</option>
		<option value="MAC">Macao</option>
		<option value="MKD">Repúblicade Macedonia</option>
		<option value="MDG">Madagascar</option>
		<option value="MYS">Malasia</option>
		<option value="MWI">Malaui</option>
		<option value="MDV">Maldivas</option>
		<option value="MLI">Malí</option>
		<option value="MLT">Malta</option>
		<option value="FLK">Islas</option>
		<option value="IMN">Islade</option>
		<option value="MNP">Islas Marianas del Norte</option>
		<option value="MAR">Marruecos</option>
		<option value="MHL">Islas</option>
		<option value="MTQ">Martinica</option>
		<option value="MUS">Mauricio</option>
		<option value="MRT">Mauritania</option>
		<option value="MYT">Mayotte</option>
		<option value="MEX">México</option>
		<option value="FSM">Micronesia</option>
		<option value="MDA">Moldavia</option>
		<option value="MCO">Mónaco</option>
		<option value="MNG">Mongolia</option>
		<option value="MNE">Montenegro</option>
		<option value="MSR">Montserrat</option>
		<option value="MOZ">Mozambique</option>
		<option value="NAM">Namibia</option>
		<option value="NRU">Nauru</option>
		<option value="CXR">Isla de Navidad</option>
		<option value="NPL">Nepal</option>
		<option value="NIC">Nicaragua</option>
		<option value="NER">Níger</option>
		<option value="NGA">Nigeria</option>
		<option value="NIU">Niue</option>
		<option value="NFK">Norfolk</option>
		<option value="NOR">Noruega</option>
		<option value="NCL">Nueva Caledonia</option>
		<option value="NZL">Nueva Zelanda</option>
		<option value="OMN">Omán</option>
		<option value="NLD">Holanda</option>
		<option value="PAK">Pakistán</option>
		<option value="PLW">Palaos</option>
		<option value="PSE">Estado de Palestina</option>
		<option value="PAN">Panamá</option>
		<option value="PNG">Papúa Nueva Guinea</option>
		<option value="PRY">Paraguay</option>
		<option value="PER">Perú</option>
		<option value="PCN">Islas Pitcairn</option>
		<option value="PYF">Polinesia Francesa</option>
		<option value="POL">Polonia</option>
		<option value="PRT">Portugal</option>
		<option value="PRI">PuertoRico</option>
		<option value="QAT">Catar</option>
		<option value="GBR">ReinoUnido</option>
		<option value="REU">Reunión</option>
		<option value="RWA">Ruanda</option>
		<option value="ROU">Rumania</option>
		<option value="RUS">Rusia</option>
		<option value="ESH">República Arabe S.D.</option>
		<option value="SLB">Islas Salomón</option>
		<option value="WSM">Samoa690</option>
		<option value="ASM">Samoa Americana</option>
		<option value="BLM">San Bartolomé</option>
		<option value="KNA">San Cristóbal y Nieves</option>
		<option value="SMR">SanMarino</option>
		<option value="MAF">SanMartín</option>
		<option value="SPM">San Pedro y Miquelón</option>
		<option value="VCT">San Vicente y las Granadin.</option>
		<option value="SHN">Santa Helena,A.yT.</option>
		<option value="LCA">Santa Lucía</option>
		<option value="STP">Santo Tomé y Príncipe</option>
		<option value="SEN">Senegal</option>
		<option value="SRB">Serbia</option>
		<option value="SYC">Seychelles</option>
		<option value="SLE">Sierra Leona</option>
		<option value="SGP">Singapur</option>
		<option value="SYR">Siria</option>
		<option value="SOM">Somalia</option>
		<option value="LKA">SriLanka</option>
		<option value="SWZ">Suazilandia</option>
		<option value="ZAF">Sudáfrica</option>
		<option value="SDN">Sudán</option>
		<option value="SSD">Sudándel</option>
		<option value="SWE">Suecia</option>
		<option value="CHE">Suiza</option>
		<option value="SUR">Surinam</option>
		<option value="SJM">Svalbard y JanMayen</option>
		<option value="THA">Tailandia</option>
		<option value="TWN">Taiwán</option>
		<option value="TZA">Tanzania</option>
		<option value="TJK">Tayikistán</option>
		<option value="IOT">Territorio Brit. Oceano Ind.</option>
		<option value="ATF">Territorios A. Franceses</option>
		<option value="TLS">TimorOriental</option>
		<option value="TGO">Togo</option>
		<option value="TKL">Tokelau</option>
		<option value="TON">Tonga</option>
		<option value="TTO">TrinidadyTobago</option>
		<option value="TUN">Túnez</option>
		<option value="TCA">IslasTurcasyCaicos</option>
		<option value="TKM">Turkmenistán</option>
		<option value="TUR">Turquía</option>
		<option value="TUV">Tuvalu</option>
		<option value="UKR">Ucrania</option>
		<option value="UGA">Uganda</option>
		<option value="URY">Uruguay</option>
		<option value="UZB">Uzbekistán</option>
		<option value="VUT">Vanuatu</option>
		<option value="VAT">CiudaddelVaticano</option>
		<option value="VEN">Venezuela</option>
		<option value="VNM">Vietnam</option>
		<option value="VGB">Islas Vírgenes Británicas</option>
		<option value="VIR">Islas Vírgenes de E.U.</option>
		<option value="WLF">Wallis y Futuna</option>
		<option value="YEM">Yemen del Norte</option>
		<option value="YDD">Yemen del Sur</option>
		<option value="DJI">Yibuti</option>
		<option value="ZMB">Zambia</option>
		<option value="ZWE">Zimbabue</option>
	</select>
</div>

<div class="fieldcontain ${hasErrors(bean: studentInstance, field: 'address', 'error')} required">
	<label for="address">
		<g:message code="student.address.label" default="Address" />
		<span class="required-indicator">*</span>
	</label>
	<g:textField name="address" required="" value="${studentInstance?.address}"/>
</div>

<div class="fieldcontain ${hasErrors(bean: studentInstance, field: 'birthplace', 'error')} ">
	<label for="birthplace">
		<g:message code="student.birthplace.label" default="Birthplace" />
		
	</label>
	<g:textField name="birthplace" value="${studentInstance?.birthplace}"/>
</div>

<div class="fieldcontain ${hasErrors(bean: studentInstance, field: 'zipcode', 'error')} ">
	<label for="zipcode">
		<g:message code="student.zipcode.label" default="Zipcode" />
		
	</label>
	<g:textField name="zipcode" value="${studentInstance?.zipcode}"/>
</div>

<div class="fieldcontain ${hasErrors(bean: studentInstance, field: 'city', 'error')} ">
	<label for="city">
		<g:message code="student.city.label" default="City" />
		
	</label>
	<g:textField name="city" value="${studentInstance?.city}"/>
</div>

<div class="fieldcontain ${hasErrors(bean: studentInstance, field: 'email', 'error')} ">
	<label for="email">
		<g:message code="student.email.label" default="Email" />
		
	</label>
	<g:textField name="email" value="${studentInstance?.email}"/>
</div>

<div class="fieldcontain ${hasErrors(bean: studentInstance, field: 'status', 'error')} ">
	<label for="status">
		<g:message code="student.status.label" default="Status" />
		
	</label>
	<g:select name="status" from="${studentInstance.constraints.status.inList}" value="${studentInstance?.status}" valueMessagePrefix="student.status" />
</div>

<div class="fieldcontain ${hasErrors(bean: studentInstance, field: 'course', 'error')} required">
	<label for="course">
		<g:message code="student.course.label" default="Course" />
		<span class="required-indicator">*</span>
	</label>
	<select id="course" name="course.id" required="" class="many-to-one" >
		<option value=""><g:message code="student.course.noselect"/></option> 
		<g:each in="${org.ikastola.Course.list()}">
			<g:if test="${studentInstance?.course?.id == it.id}"><option value="${it.id}" selected="selected"></g:if>	
			<g:else><option value="${it.id}"></g:else>
			${it.name+' '+it.division+' '} <g:if test="${it.shift == 1}"><g:message code="course.shift.1" /></g:if><g:else><g:message code="course.shift.2" /></g:else>
			</option>
		</g:each>
	</select>	
</div>

<div class="fieldcontain ${hasErrors(bean: studentInstance, field: 'active', 'error')} ">
	<label for="active">
		<g:message code="student.active.label" default="Active" />
		
	</label>
	<g:select name="active" from="${studentInstance.constraints.active.inList}" value="${studentInstance?.active}" valueMessagePrefix="student.active" />
</div>

<div class="fieldcontain ${hasErrors(bean: studentInstance, field: 'admdate', 'error')} required">
	<label for="admdate">
		<g:message code="student.admdate.label" default="Admdate" />
		<span class="required-indicator">*</span>
	</label>
	<g:datePicker name="admdate" precision="day"  value="${studentInstance?.admdate}"  />
</div>

<div class="fieldcontain ${hasErrors(bean: studentInstance, field: 'guardians', 'error')} ">
	<label for="guardians">
		<g:message code="student.guardians.label" default="Guardians" />
		
	</label>
	<g:select name="guardians" optionValue="${{it.name+' '+it.lastname}}" from="${org.ikastola.Guardian.list()}" multiple="multiple" optionKey="id" value="${studentInstance?.guardians*.id}" class="many-to-one" />
	<g:if test="${studentInstance?.id}">
		<g:link controller="guardian" action="create"  params='[st: "${studentInstance?.id}"]'>Agregar</g:link>
	</g:if>
</div>

<div class="fieldcontain ${hasErrors(bean: studentInstance, field: 'relatives', 'error')} ">
	<label for="relatives">
		<g:message code="student.relatives.label" default="Relatives" />
		
	</label>
	<select name="relatives" multiple="multiple" size="5" class="many-to-many" id="relatives" >
		<g:each in="${org.ikastola.Student.list()}">
			<g:if test="${studentInstance?.id != it.id}">
				<g:if test="${studentInstance?.isRelative(it.id)}" >
					<option value="${it.id}" selected="selected"> ${it.name} ${it.lastname} </option>
				</g:if>
				<g:else>
					<option value="${it.id}"> ${it.name} ${it.lastname} </option>
				</g:else>
			</g:if>
		</g:each>
	</select>
</div>

<div class="fieldcontain ${hasErrors(bean: studentInstance, field: 'items', 'error')} ">
	<label for="service">
		<g:message code="student.service.label" default="Service" />
		
	</label>
	<g:select name="fees" optionValue="${{it.name}}" from="${org.ikastola.Fee.list()}" multiple="multiple" optionKey="id" value="${studentInstance?.fees*.id}" class="many-to-one" />
	<g:select name="disc" optionValue="${{it.name}}" from="${org.ikastola.Discount.list()}" multiple="multiple" optionKey="id" value="${studentInstance?.disc*.id}" class="many-to-one" />
</div>



